import { ref } from 'vue'
import { defineStore } from 'pinia'
import { userGetInfoService } from '@/api/user'

export const useUserStore = defineStore('store-user', () => {

  const user = ref<Record<string, any>>({})

  const getUser = async (username: string) => {
    const res = await userGetInfoService(username)
    user.value = res.data.data
  }
  const setUser = (newUser: any) => (user.value = newUser)
  return {
    user,
    getUser,
    setUser
  }
}, { persist: true }

)
